#include "instructionmenusecond.h"
#include "ui_instructionmenusecond.h"
#include "buttonfunctionmap.h"

InstructionMenuSecond::InstructionMenuSecond(ButtonFunctionMap *funcMapIn,
                                             QWidget *parent) :
    QWidget(parent),
    ui(new Ui::InstructionMenuSecond)
{
    ui->setupUi(this);
    funcMap=funcMapIn;
    initialButtonText();
    ui->nextPage_Btn->hide();
}

InstructionMenuSecond::~InstructionMenuSecond()
{
    delete ui;
}

void InstructionMenuSecond::changeLanguage()
{
    ui->retranslateUi(this);
    initialButtonText();
}

void InstructionMenuSecond::on_forwardPage_Btn_clicked()
{
    emit oftenForwardPage();
}

void InstructionMenuSecond::on_button_robotControl_clicked()
{
//    emit addRobotMoveInstruction_Signal();
    funcMap->emitSignalByButtonId(20);
}

void InstructionMenuSecond::on_button_roller_clicked()
{
//    emit addRollerInstruction_Signal();
    funcMap->emitSignalByButtonId(21);
}

void InstructionMenuSecond::on_button_waitCommand_clicked()
{
//    emit addWaitCommandInstruction_signal();
    funcMap->emitSignalByButtonId(22);
}

void InstructionMenuSecond::on_button_music_clicked()
{
//    emit musicInstruction();
    funcMap->emitSignalByButtonId(23);
}

void InstructionMenuSecond::on_button_lift_clicked()
{
//    emit liftMechanismInstruction();
    funcMap->emitSignalByButtonId(24);
}

void InstructionMenuSecond::on_button_charge_clicked()
{
//    emit chargingInstruction();
    funcMap->emitSignalByButtonId(25);
}

void InstructionMenuSecond::on_button_batteryJudgement_clicked()
{
//    emit addCheckBatteryInstruction_signal();
    funcMap->emitSignalByButtonId(26);
}

void InstructionMenuSecond::on_button_loadMap_clicked()
{
//    emit addLoadMapInstruction_signal();
    funcMap->emitSignalByButtonId(27);
}


void InstructionMenuSecond::on_button_fun28_clicked()
{
    funcMap->emitSignalByButtonId(28);
}

void InstructionMenuSecond::on_button_fun29_clicked()
{
    funcMap->emitSignalByButtonId(29);
}

void InstructionMenuSecond::on_button_fun30_clicked()
{
    funcMap->emitSignalByButtonId(30);
}

void InstructionMenuSecond::on_button_fun31_clicked()
{
    funcMap->emitSignalByButtonId(31);
}


void InstructionMenuSecond::initialButtonText()
{


    for(int i=20;i<32;i++)
    {
        QString tmpText=funcMap->getFunctionTextByButtonId(i);
        switch(i)
        {
        case 20:
            if(tmpText.size()>0)
            {
                ui->button_robotControl->setText(tmpText);
            }
            else
            {
                ui->button_robotControl->hide();
            }

        break;
        case 21:
            if(tmpText.size()>0)
            {
                ui->button_roller->setText(tmpText);
            }
            else
            {
                ui->button_roller->hide();
            }
        break;
        case 22:
            if(tmpText.size()>0)
            {
                ui->button_waitCommand->setText(tmpText);
            }
            else
            {
                ui->button_waitCommand->hide();
            }

        break;
        case 23:
            if(tmpText.size()>0)
            {
                ui->button_music->setText(tmpText);
            }
            else
            {
                ui->button_music->hide();
            }

        break;
        case 24:
            if(tmpText.size()>0)
            {
                ui->button_lift->setText(tmpText);
            }
            else
            {
                ui->button_lift->hide();
            }

        break;
        case 25:
            if(tmpText.size()>0)
            {
                ui->button_charge->setText(tmpText);
            }
            else
            {
                ui->button_charge->hide();
            }

        break;
        case 26:
            if(tmpText.size()>0)
            {
                ui->button_batteryJudgement->setText(tmpText);
            }
            else
            {
                ui->button_batteryJudgement->hide();
            }

        break;
        case 27:
            if(tmpText.size()>0)
            {
                ui->button_loadMap->setText(tmpText);
            }
            else
            {
                ui->button_loadMap->hide();
            }


        break;
        case 28:
            if(tmpText.size()>0)
            {
                ui->button_fun28->setText(tmpText);
            }
            else
            {
                ui->button_fun28->hide();
            }

        break;
        case 29:
            if(tmpText.size()>0)
            {
                ui->button_fun29->setText(tmpText);
            }
            else
            {
                ui->button_fun29->hide();
            }

        break;
        case 30:
            if(tmpText.size()>0)
            {
                ui->button_fun30->setText(tmpText);
            }
            else
            {
                ui->button_fun30->hide();
            }

        break;
        case 31:
            if(tmpText.size()>0)
            {
                ui->button_fun31->setText(tmpText);
            }
            else
            {
                ui->button_fun31->hide();
            }

        break;
        }
    }
}


